<template>
  <div id="app">
    <header class="head">
      <a class="back tl" href="javascript:history.back(-1)">
        <i class="el-icon-arrow-left"></i>
      </a>
      <a href="javascript:;" class="tc">
        <small class="font_18 co_f">闲置土地档案</small>
      </a>
    </header>
    <main>
      <div class="seachfrom">
        <div class="seachbox">
          <el-input placeholder="请输入内容" v-model="seachtext">
            <el-button slot="append" icon="search" @click="seach()"></el-button>
          </el-input>
        </div>
      </div>
      <div>
        <section class="item-title">
          搜索到：房产处数:<span>2222</span> 闲置面积：<span>1111</span>
        </section>
        <v-loadmore :top-method="loadTop" :bottom-method="loadBottom" :auto-fill="false" ref="loadmore">
          <ul class="datalist">
            <li v-for="item in listData" :key='item.unid'>
              <router-link :to='{name: "Munedetail"}'>
                <div class="items-img">
                  <img src="../../img/shop.png" />
                </div>
                <div class="items-text">
                  <p>地址: {{item.enterprisePerson.name}}</p>
                  <p>闲置面积：<span>{{item.enterprisePerson.healthCode}}</span></p>
                  <p>关联土地：<span>{{item.morningRecordContent}}</span></p>
                </div>
              </router-link>
            </li>
          </ul>
        </v-loadmore>
        <div class="none_data" v-show="nonedata">
          <img src="../../img/tip.png">
        </div>
      </div>
    </main>
  </div>
</template>

<script type="text/ecmascript-6">
  /*过滤器*/
  import {
    Loadmore
  } from 'mint-ui';
  import {
    MorningRecord
  } from '../../api/api';
  
  export default {
    components: {
      'v-loadmore': Loadmore,
    },
    data() {
      return {
        options: [{
          value: '√',
          label: '正常'
        }, {
          value: '△',
          label: '发热'
        }, {
          value: '⊙',
          label: '腹泻'
        }, {
          value: '﹟',
          label: '皮肤溃疡'
        }, {
          value: '※',
          label: '其他传染病'
        }, {
          value: '不在岗',
          label: '不在岗位'
        }],
        nonedata: false,
        PageSize: 5,
        CurrentPage: 1,
        CriteriaList: [],
        listData: [],
        seachtext: '',
        select: '',
        scrollMode: "auto"
      };
    },
    methods: {
      loadTop: function() { //组件提供的下拉触发方法  
        //下拉刷新
        if (this.CurrentPage >= 0) {
          this.CurrentPage = 1;
          this.listData = [];
          this.getData();
        } else {
          this.listData = [];
          this.getData();
        }
        this.$refs.loadmore.onTopLoaded(); // 固定方法，查询完要调用一次，用于重新定位  
      },
      loadBottom: function() {
        // 上拉加载  
        this.CurrentPage += 1;
        this.getData();
        // 上拉触发的分页查询  
  
        //this.allLoaded = true;
        this.$refs.loadmore.onBottomLoaded(); // 固定方法，查询完要调用一次，用于重新定位  
      },
      //搜索
      seach: function() {
        this.listData = [];
        this.CurrentPage = 1;
        this.CriteriaList[0] = {
          Name: 'EnterprisePerson.Name',
          Value: '%' + this.seachtext + '%',
          Operate: 'Like',
          DataType: null,
          EndSuffix: '',
          Suffix: null
        };
        this.CriteriaList[1] = {
          Name: 'EnterprisePerson.SerialNumber',
          Value: '%' + this.seachtext + '%',
          Operate: 'Like',
          DataType: null,
          EndSuffix: '',
          Suffix: null
        };
        this.getData();
      },
      //数据加载方法
      getData() {
        let CurrentPageNum = this.CurrentPage
        let varQueryData = {
          PageSize: this.PageSize,
          CurrentPage: this.CurrentPage,
          Query: {
            CriteriaList: [],
            SubQueryList: []
          }
        }
        if (this.CriteriaList.length !== 0) {
          let SubQueryList = [{
            CriteriaList: this.CriteriaList,
            Relation: 'or'
          }]
          varQueryData.Query.SubQueryList = SubQueryList;
        }
        let options = {
          params: {
            UserUnid: JSON.parse(localStorage.getItem('auth')).UserUnid,
            QueryData: JSON.stringify(varQueryData)
          }
        }
        //调取接口
        MorningRecord(options).then((res) => {
          if (res.success === true) {
            this.user = res.data.user;
            this.listData = this.listData.concat(res.data);
            if (res.data.length > 0) {
              this.nonedata = false
            } else {
              if (CurrentPageNum == 1) {
                this.nonedata = true
              } else {
                this.nonedata = false
              }
            }
          }
        })
      }
    },
  
    //页面加载时候
    mounted() {
      this.getData()
    }
  
  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->

<style lang="scss" scoped>
 
</style>
